package cn.it.http.dao.impl;

import cn.it.http.dao.BaseDao;
import cn.it.http.dao.UserDao;
import cn.it.http.entity.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class UserDaoImpl extends BaseDao implements UserDao {
    private Connection conn;

    private ResultSet rs;
    @Override
    public User login(User user) {

        try {
            conn=super.getConnection();
            String sql="select * from student where name=? and password=?";
            PreparedStatement preparedStatement = conn.prepareStatement(sql);
            rs=preparedStatement.executeQuery();
            preparedStatement.setObject(1,user.getUsername());
            preparedStatement.setObject(2,user.getPwd());
            if (rs.next()){
                User user1 = new User();
                user1.setUsername(rs.getString("name"));
                user1.setPwd(rs.getString("password"));
            }


        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
